
class TreeNode{
    public int val;
    public TreeNode left;
    public TreeNode right;
    public TreeNode(int val){
        this.val=val;
    }
}
public class BinaryTree {
    //获取树中节点的个数
    int count=0;
    public int size(TreeNode root){
        if(root==null){
            return 0;
        }
        count++;
        size(root.left);
        size(root.right);
        return count;
    }

    /* public int size(TreeNode root){
        if(root==null){
            return 0;
        }
        return size(root.left)+size(root.right)+1;
    }*/

}
